
function clearError() {
    var phoneError = document.getElementById('phoneError');
    phoneError.textContent = '';
}

function validatePhone() {
    var phoneInput = document.getElementById('phone');
    var phoneError = document.getElementById('phoneError');
    var phoneRegex = /^\d{11}$/;

    if (phoneInput.value.trim() === '') {
        phoneError.textContent = '请输入手机号码';// 没写手机号码
    } else if (!phoneRegex.test(phoneInput.value)) {
        phoneError.textContent = '请输入正确的11位手机号码'; // 手机号码写错 
    } else {
        phoneError.textContent = ''; // 手机号码正确或格式符合要求 
    }
}
window.onload=function(){
    document.getElementById('loginForm').addEventListener('submit', function(event) {
    event.preventDefault(); 
    var phoneInput = document.getElementById('phone').value;
    var passwordInput = document.getElementById('password').value;

    if (phoneInput === '19928554831' && passwordInput === '123456') {
        alert('登录成功');
        window.location.href ="../index.html"
    } else {
        alert('手机号码或密码不正确');
    }
});
}
